<?php
/**
 * Created by PhpStorm.
 * User: qgkjtech
 * Date: 2017/10/12
 * Time: 下午10:26
 * 封装的Server,由所有的进程共享
 */

require_once "ClientRequestProcess.php";
require_once "ServerContext.php";
require_once "ServerResponse.php";
require_once __DIR__ . '/../Object/NiuNiuRoomManager.php';
require_once __DIR__ . '/../Object/MaJang/MajangRoomManager.php';

class GameServer{
    public $serverProcess;         //用于处理客户端相应的处理器
    public $serverContext;         //用于保存服务器总环境的对象
    public $serverResponse;        //用于处理服务器返回客户端的对象
    public $niuNiuRoomManager;

    public $majongRoomManager;     //用于处理麻将房间的管理


    function __construct()
    {
        $this->serverContext = new ServerContext();
        $this->serverProcess = new ClientRequestProcess();
        $this->serverResponse = new ServerResponse();
        $this->niuNiuRoomManager=new NiuNiuRoomManager();
        $this->majongRoomManager = new MajangRoomManager();
    }

    /*
     *  二次封装的服务器处理客户端响应的函数
     * @param $connectionID 连接ID 客户端请求数据
     */
    function processClientRequest($connectionID, $clientRequest)
    {
        $this->serverProcess->processClientRequest($connectionID, $clientRequest,$this);//执行消息分发函数 得到结果
    }

    function processServerResponse($responseType,$userUid,$responseMsg){
        $this->serverResponse->processServerResponse($responseType,$userUid, $responseMsg);//响应服务器返回
    }

}



?>